<?php
/**
 * Created by Command.
 * User: Vito
 */

namespace app\admin\curd\system_auth;

use app\common\curd\Read;
use app\exception\MessageException;
use app\admin\curd\system_role\SystemRoleTrait;

class SystemAuthRead extends Read
{
    use SystemRoleTrait;

    //需要展示的字段
    protected $field = [];
    //排除字段
    protected $withoutField = false;
    //追加输出的属性
    protected $append = [];
    //条件
    protected $where = [];

    protected function readMiddleware($next, $model)
    {
        $ids = $this->getHasAuthId();

        if (is_array($ids) && !in_array($model->id, $ids)) {
            throw new MessageException('无权限获取');
        }

        return parent::readMiddleware($next, $model); // TODO: Change the autogenerated stub
    }
}
